<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="lib/layui/css/layui.css"/>
</head>
<body style="padding-top: 16px;padding-right: 30px;">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">原密码</label>
        <div class="layui-input-block">
            <input type="password" name="oldpwd" required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
            <input type="password" name="newpwd" required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认新密码</label>
        <div class="layui-input-block">
            <input type="password" name="reviewpwd" required  lay-verify="required" placeholder="请再次输入新密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="account">提交</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/sha.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="lib/layui/layui.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script>
    var queryObj=parseUrlParams()
    layui.use(['form','layer'], function(){
        var form = layui.form;
        var layer=layui.layer;
        // form.verify({
        //     mpassword:function(value, item) {
        //         if (!new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,30}').test(value)) {
        //             return '请输入新密码，需包含特殊字符、字母、数字,8-30位字符!';
        //         }
        //     }
        // });
        //监听提交
        form.on('submit(account)', function(data){
            if(data.field.reviewpwd!=data.field.newpwd){
                layer.msg("两次输入新密码不一致");
                return false;
            }
            var obj = {
                ip: decodeURIComponent(queryObj.ip),
                old: md5('admin' + data.field.oldpwd),
                new: md5('admin' + data.field.newpwd)
            }
            httpPost('zigbee/account/save',obj,function(res){
               if(res.code===0){
                   layer.msg("修改成功");
                   setTimeout(function(){
                       var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                       parent.layer.close(index); //再执行关闭
                   },1000)
               }else{
                   layer.msg(res.msg);
               }
            })
            return false;
        });
    });



</script>
</body>
</html>